<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>
    <script type="text/javascript">
        var $bn_shop_map = new Object();
        $(function() {

            submitForm = function( $dialog, $gird){
                $('#bn_shop_form').form('submit',{
                    url:'${ctx}/bn/shop/uncheck/update',
                    queryParams:{_m:'exec'},
                    onSubmit:function(){
                        if($(this).form('enableValidation').form('validate')){
                            if($("#bigPic").val() == ""){
                                parent.$.messager.alert("提示",errMsg("请上传店铺详细照片！"),"error");
                                return false;
                            }else if($("#mediumPic").val() == ""){
                                parent.$.messager.alert("提示",errMsg("请上传店铺展示照片！"),"error");
                                return false;
                            }
                            return true;
                        }else{
                            return false;
                        }
                    },
                    success:function(data){
                        var json =  eval("(" +data+ ")");
                        if(statusMsg(json)){
                            parent.$.messager.alert("提示","保存成功！","info",function(){
                                $dialog.dialog('destroy');
                                $gird.datagrid('reload');
                            });
                        }
                    }
                });
            };

            //店铺详细图
            $("#inputfile").change(function(){
                var filedata = $(this).val();
                if (filedata == "" || filedata == null) {
                    parent.$.messager.alert("提示", errMsg("请选择上传文件！"), "error");
                    return;
                }

                var uploadFileType="PNG|JPG";
                var array = filedata.split(".");
                var type = array[1];
                if(uploadFileType.indexOf(type.toUpperCase())==-1){
                    parent.$.messager.alert("提示", errMsg("格式不正确，只能为PNG|JPG当中的一种！"), "error");
                    return
                }
                parent.$.messager.progress({
                    text : '正在上传，请稍后...'
                });

                $("#upload_form").ajaxSubmit({
                    type: "POST",
                    url:'${ctx}/bn/shop/uncheck/update?_m=upload&r='+Math.random(),
                    success: function(data){
                        parent.$.messager.progress('close');
                        if(statusMsg(data)){
                            $("#bigPic").val(data.msg);
                            var h = '<img src="'+data.msg+'" width="350"/>';
                            $("#imgUrl").html(h);
                        }
                    },
                    error:function(){
                        parent.$.messager.progress('close');
                    }
                });

            })

            //店铺展示图
            $("#inputfile1").change(function(){
                var filedata = $(this).val();
                if (filedata == "" || filedata == null) {
                    parent.$.messager.alert("提示", errMsg("请选择上传文件！"), "error");
                    return;
                }

                var uploadFileType="PNG|JPG";
                var array = filedata.split(".");
                var type = array[1];
                if(uploadFileType.indexOf(type.toUpperCase())==-1){
                    parent.$.messager.alert("提示", errMsg("格式不正确，只能为PNG|JPG当中的一种！"), "error");
                    return
                }
                parent.$.messager.progress({
                    text : '正在上传，请稍后...'
                });

                $("#upload_form1").ajaxSubmit({
                    type: "POST",
                    url:'${ctx}/bn/shop/uncheck/update?_m=uploadother&r='+Math.random(),
                    success: function(data){
                        parent.$.messager.progress('close');
                        if(statusMsg(data)){
                            $("#mediumPic").val(data.msg);
                            $("#smallPic").val(data.msg+"?x-oss-process=image/resize,m_fixed,h_110,w_110");
                            var h = '<img src="'+data.msg+'" width="236"/>';
                            $("#imgUrl1").html(h);
                        }
                    },
                    error:function(){
                        parent.$.messager.progress('close');
                    }
                });
            })

            //服务类型
            $('#serviceClassifyCode').combobox({
                onChange : function(){
                    var v = $("#serviceClassifyCode").combobox("getValue") ;
                    $('#serviceTypeCode').combobox({
                        url:'${ctx}/api/cdcooperativeshopstype/servicetype?parent='+ v,
                        valueField:'code',
                        textField:'name'
                    });

                    $('#serviceTypeCode').combobox('setValue','');
                }
            });


            //打开地图
            openmap = function (){
                var lat = $("#lat").val();
                var lng = $("#lng").val();
                viewDialog_map=parent.$.dialog({
                    title: '查看地图',
                    href: '${ctx}/bn/shop/uncheck/update?_m=updateshowmap&lat='+lat+'&lng='+lng+'&r='+Math.random(),
                    width: 800,
                    height: 550,
                    buttons: [{
                        text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>&nbsp;选 择',
                        width:'70px',
                        handler: function(){
                            viewDialog_map.find('iframe').get(0).contentWindow.submitForm(viewDialog_map,$bn_shop_map);
                        }
                    },{
                        text:'<i class="fa fa-reply" aria-hidden="true"></i>&nbsp;返 回',
                        width:'70px',
                        handler: function(){
                            viewDialog_map.close();
                        }
                    }]
                });
            }

            //设置经纬度
            $bn_shop_map.setjwd = function(lngX,latY,address){
                $("#lng").val(lngX);
                $("#lat").val(latY);
                $("#address").val(address);
            }
        });

    </script>
</head>
<body>
<div class="form-box">
    <div class="form-body">
        <form role="form" method="POST" name="bn_shop_form" id="bn_shop_form" class="easyui-form form form-horizontal" data-options="novalidate:true">
            <input type="hidden" id="shopId" name="shopId" value="${bnShopEntity.shopId}"/>
            <input type="hidden" id="bigPic" name="bigPic" value="${bnShopEntity.bigPic}"/>
            <input type="hidden" id="mediumPic" name="mediumPic" value="${bnShopEntity.mediumPic}"/>
            <input type="hidden" id="smallPic" name="smallPic" value="${bnShopEntity.smallPic}"/>
            <div class="seg-title">
                <div class="seg-title-box">
                    <ul>
                        <li class="seg-title-box-icon" ><img src="${ctx }/assets/images/communication.gif"/></li>
                        <li class="seg-title-box-text">基本信息</li>
                    </ul>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">店铺名称：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-8">
                    <input type="text" id="shopName" name="shopName" value="${bnShopEntity.shopName}" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" required="required" validType="length[1,50]">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">店铺简称：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-8">
                    <input type="text" id="shopShortName" name="shopShortName" value="${bnShopEntity.shopShortName}" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" required="required" validType="length[1,50]">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">服务分类：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="serviceClassifyCode" name="serviceClassifyCode" value="${bnShopEntity.serviceClassifyCode}" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" data-options="valueField: 'code',textField: 'name',url:'${ctx}/tcode/all/method?method=getCacheCdCooperativeShopsTypeParent',editable:false" required="required"/>
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">服务类型：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="serviceTypeCode" name="serviceTypeCode" value="${bnShopEntity.serviceTypeCode}" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" data-options="valueField: 'code',textField: 'name',url:'${ctx}/api/cdcooperativeshopstype/servicetype?parent=${bnShopEntity.serviceClassifyCode}',editable:false"  required="required"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">联系电话：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="phone" name="phone" value="${bnShopEntity.phone}" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" required="required" validType="length[1,20]">
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">邮编：</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="code" name="code" value="${bnShopEntity.code}" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" validType="length[1,6]">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">详细地址：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-8">
                    <input type="text" id="address" name="address" value="${bnShopEntity.address}" onclick="openmap()" class="form-control easyui-validatebox" style="cursor: pointer;width:100%;height:34px;line-height:34px;" required="required" validType="length[1,100]">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">经度：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="lng" name="lng" onclick="openmap()" value="${bnShopEntity.lng}" class="form-control easyui-validatebox" style="cursor: pointer;width:100%;height:34px;line-height:34px;" required="required" data-options="editable:false">
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">纬度：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="lat" name="lat" onclick="openmap()" value="${bnShopEntity.lat}" class="form-control easyui-validatebox" style="cursor: pointer;width:100%;height:34px;line-height:34px;" required="required" data-options="editable:false">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">省份：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="provinceCode" name="provinceCode" value="${bnShopEntity.provinceCode}" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="
                    valueField: 'label',
                    textField: 'value',
                    data: [{
                        label: '22',
                        value: '吉林省'
                    }],editable:false"/>
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">地级市：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="cityCode" name="cityCode" value="${bnShopEntity.cityCode}" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="valueField: 'code',textField: 'name',url:'${ctx}/tcode/all/method?method=getCacheCdCity',editable:false"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">区县市：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="countyCode" name="countyCode" value="${bnShopEntity.countyCode}"  class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="valueField: 'code',textField: 'name',url:'${ctx}/tcode/all/method?method=getCacheCdCounty',editable:false"/>
                </div>
            </div>
        </form>
        <form role="form" name="upload_form" id="upload_form" class="easyui-form form form-horizontal" data-options="novalidate:true"  enctype="multipart/form-data">
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">店铺详情图片：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-8">
                    <button type="button" class="btn btn-info btn-squared btn-lg" onclick="getElementById('inputfile').click();">
                        图片上传 <i class="fa fa-arrow-circle-o-up fa-1x"></i>
                    </button>
                    <input type="file" name="inputfile"　multiple="multiple" style="opacity:0;filter:alpha(opacity=0);height:5px;" id="inputfile"/>
                    <div id="imgUrl"  style="width:500px;text-align: left;overflow: hidden;">
                        <img src="${bnShopEntity.bigPic}" width="350"/>
                    </div>
                </div>
            </div>
        </form>
        <form role="form" name="upload_form1" id="upload_form1" class="easyui-form form form-horizontal" data-options="novalidate:true"  enctype="multipart/form-data">
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">店铺展示图片：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-8">
                    <button type="button" class="btn btn-info btn-squared btn-lg" onclick="getElementById('inputfile1').click();">
                        图片上传 <i class="fa fa-arrow-circle-o-up fa-1x"></i>
                    </button>
                    <input type="file" name="inputfile1"　multiple="multiple" style="opacity:0;filter:alpha(opacity=0);height:5px;" id="inputfile1"/>
                    <div id="imgUrl1"  style="width:500px;text-align: left;overflow: hidden;">
                        <img src="${bnShopEntity.mediumPic}" width="236"/>
                    </div>
                </div>
            </div>
        </form>
        <div style="padding-top:50px;"></div>
    </div>
</div>
</body>
</html>